var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    section: [{
      name: '优惠券',
      typeId: '1'
    }, {
      name: '代金券',
      typeId: '2'
    }
    ],
    currentId: '1',
    seleNull: null,
    seleNulls: null,
    seleNullss: null,
    array: ['是', '否'],
    arrayss: ['是', '否'],
  },


  onLoad: function (options) {
  },
  handleTap: function (e) {
    var id = e.currentTarget.id;
    this.setData({
      currentId: id,
      zd_price: ''
    })
  },
  bindPickerChange: function (e) {
    this.setData({
      seleNulls: '0',
      index: e.detail.value
    })
  },
  bindDateChange: function (e) {
    this.setData({
      seleNull: '0',
      date: e.detail.value
    })
  },
  bindPickerChangess: function (e) {
    this.setData({
      seleNullss: '0',
      indexs: e.detail.value
    })
  },

  setYhqTitle:function(e){
    this.setData({
      yhqtitle:e.detail.value
    })
  },

  setYhqFull:function(e){
    this.setData({
      full:e.detail.value
    })
  },

  setYhqReduce:function(e){
    this.setData({
      reduce:e.detail.value
    })
  },

  setDjqTitle:function(e){
    this.setData({
      djqtitle:e.detail.value
    })
  },

  setDjqPrice:function(e){
    this.setData({
      price:e.detail.value
    })
  },

  setDjqDkprice:function(e){
    this.setData({
      dk_price:e.detail.value
    })
  },

  yhqtijiao:function(e){
    var t = this;
    if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.full))) {
      app.myToast("所猜价格只能输入数字！")
    }else if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.reduce))) {
      app.myToast("所猜价格只能输入数字！")
    }else{
      app.visit("huodong/setYouHuiQuanInfos", {
        store_id:wx.getStorageSync("store_id"),
        title:t.data.yhqtitle,
        full:t.data.full,
        reduce:t.data.reduce,
        date:t.data.date,
        index:t.data.index,
      }, "", function(c) {
        console.log(c)
        if(0 == c.code){
          wx.showToast({
            title: '添加成功',
            icon: 'none',
            success: function () {
              wx.navigateBack();
            }
          })
        }else{
          app.showToast(c.msg)
        }
      })
    }
  },

  djqtijiao:function(e){
    var t = this;
    if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.price))) {
      app.myToast("所猜价格只能输入数字！")
    }else if (!(/(^[0-9]+(.[0-9]{1,2})?$)/.test(t.data.dk_price))) {
      app.myToast("所猜价格只能输入数字！")
    }else{
      app.visit("huodong/setDaiJinQuanInfos", {
        store_id:wx.getStorageSync("store_id"),
        title:t.data.djqtitle,
        price:t.data.price,
        dk_price:t.data.dk_price,
        index:t.data.indexs,
      }, "", function(c) {
        console.log(c)
        if(0 == c.code){
          wx.showToast({
            title: '增加成功',
            icon: 'none',
            success: function () {
              wx.navigateBack();
            }
          })
        }else{
          app.showToast(c.msg)
        }
      })
    }
  },

})